/*
 *  Brno University of Technology
 *
 *  Copyright (C) 2009-2010 by Brno University of Technology and the contributors
 *
 *  Complete list of developers available at our web site:
 *
 *       http://spl.utko.feec.vutbr.cz
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/.
 */
package cz.vutbr.feec.utko.ef.individuals;

import java.io.Serializable;

import cz.vutbr.feec.utko.ef.grammar.Rule;

/**
 * The Class Action defines action which can be performed on a tree node in a
 * Chromozome.
 */
public abstract class ActionTree extends Action implements Cloneable, Serializable {
	
	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = -708382462041899882L;
	
	/** The rule. */
	Rule rule;
	
	/** The is input parameter. */
	private boolean isInputParameter = false;

	/**
	 * Gets the rule.
	 * 
	 * @return the rule
	 */
	public Rule getRule() {
		return rule;
	}
	
	/**
	 * Gets the symbol to be displayed in a tree visualization.
	 * 
	 * @return the symbol
	 */
	public abstract String getSymbol();

	/**
	 * Checks if is input parameter.
	 * 
	 * @return true, if is input parameter
	 */
	public boolean isInputParameter() {
		return isInputParameter;
	}

	/**
	 * Sets the input parameter.
	 * 
	 * @param isInputParameter
	 *            the new input parameter
	 */
	public void setInputParameter(boolean isInputParameter) {
		this.isInputParameter = isInputParameter;
	}
	
	/**
	 * Sets the rule.
	 * 
	 * @param rule
	 *            the new rule
	 */
	public void setRule(Rule rule) {
		this.rule = rule;
	}
	
	/**
	 * Initialize an action. This action is used only by terminals and
	 * initializes terminal value when the chromozome is constructed.
	 */
	public void initialize() {
		throw new RuntimeException("The action '" + this.getClass().getName()
				+ "' (" + getSymbol()
				+ ") assigned to rule does not override class the "
				+ "'initialize' method. It is required for terminal "
				+ "initialization.");
	}
}
